/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;

/**
 *
 * @author asall
 */
public class Diplome {
    static Connexion con= new Connexion();
                
   public String getLibelle(int idDiplome) {
		String res="libelle diplome";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select libelle_diplome from Diplome"
							+ " where id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_diplome"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     

public String getEffectif(int idDiplome) {
		int eff=0;
                String res=""+eff;
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select effectif from Diplome"
							+ " where id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				eff = (resultatDest.getInt("effectif"));
				res=""+eff;
                                return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}
       public String getCodeLmd(int idDiplome) {
		String res="code lmd2";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select code_lmd2 from Diplome"
							+ " where id_dip= "+ idDiplome );
			while (resultatDest.next()) {
				res=(resultatDest.getString("code_lmd2"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}      

       public String getTypeDiplome(int idDiplome) {
		String res="type diplome";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select typ.libelle_type_dip"
                                + " from diplome di, type_diplome typ "
                                + " where di.fid_type_dip= typ.id_type_dip"
                                + " and di.id_dip= " + idDiplome );
			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_type_dip"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}      
}
